package com.xbongbong.paas.factory;

import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.help.optional.range.UserDeptOptionalRangeHandler;
import com.xbongbong.paas.help.optional.range.impl.DeptNameHandlerImpl;
import com.xbongbong.paas.help.optional.range.impl.RoleNameHandlerImpl;
import com.xbongbong.paas.help.optional.range.impl.UserNameHandlerImpl;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;

/**
 * @Description 用户部门自定义可选范围工厂
 * @param
 * @return
 * @author sunshaoxaing
 * @Date  2021/09/23 9:45
 * @since
 **/
public class UserDeptOptionalRangeFactory {
    /**
     * 用户部门自定义可选范围字段处理声明
     * @param fieldType
     * @return
     */
    public static UserDeptOptionalRangeHandler getHandlerByFieldType(Integer fieldType) throws XbbException {
        FieldTypeEnum fieldTypeEnum = FieldTypeEnum.getFieldTypeEnum(fieldType);
        switch (fieldTypeEnum) {
            case USER_NAME:
                return new UserNameHandlerImpl();
            case DEPT_NAME:
                return new DeptNameHandlerImpl();
            case ROLE_NAME:
                return new RoleNameHandlerImpl();
            default:
                throw new XbbException(SystemErrorCodeEnum.API_ERROR_100001, SystemErrorCodeEnum.API_ERROR_100001.getMsg());
        }
    }
}
